<template>
	<el-dialog title="档案借阅申请对话框" v-model="visible" width="600px" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="left">
			<el-form-item label="档案标题" prop="archivesTitle">{{form1.archivesTitle}}
			</el-form-item>
			<el-form-item label="借阅标题" prop="title">
				<el-input v-model="form.title" placeholder="借阅标题" clearable maxlength="100"></el-input>
			</el-form-item>
			<el-form-item label="是否出库">
				<el-radio-group v-model="form.toOut">
					<el-radio-button label="0">不出库</el-radio-button>
					<el-radio-button label="1">出库</el-radio-button>
				</el-radio-group>
			</el-form-item>
			<el-form-item label="借阅时长" prop="beginToEnd">
				<el-date-picker v-model="form.beginToEnd" placeholder="签订日期" type="daterange" value-format="YYYY-MM-DD" style="width: 100%;"></el-date-picker>
			</el-form-item>
			<el-form-item label="借阅说明">
				<el-input v-model="form.remark" placeholder="借阅说明" clearable maxlength="380" type="textarea"></el-input>
			</el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">确认</el-button>
		</template>
	</el-dialog>

</template>
<script>

export default {
	emits: ['success', 'closed'],
	components: {
	},
	data() {
		return {
			visible: false,
			isSaveing: false,
			form:{
				archivesId:'',
				title:'',
				beginToEnd:[],
				toOut:'0',
				remark:''
			},
			form1: {
				recordId:'',
				archivesTitle:'',

			},
			options: [],
			rules: {
				beginToEnd: [
					{required: true, message: '借阅时长不能为空', trigger: 'blur'}
				],
				借阅标题: [
					{required: true, message: '借阅标题不能为空', trigger: 'blur'}
				],
			}
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open() {
			this.visible = true;
			return this
		},
		submit() {
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					var res = await this.$API.archives.archivesBorrowing.createArchivesBorrowingRule.post(this.form);
					this.isSaveing = false;
					if (res.code == 200) {
						this.$nextTick(() => {
							this.$router.replace({
								path: '/bpm/handle/dowork',
								query:{
									runId:res.data.runId,
									stepRunId:res.data.stepRunId,
									flowId:res.data.flowId
								}
							})
							this.visible = false;
							this.$message.success("操作成功")
						})
					} else {
						this.$alert(res.message, "提示", {type: 'error'})
					}
				}
			})
		},
		setData(data) {
			this.form.archivesId = data.recordId
			this.form1.archivesTitle = data.title
		},
	}
}
</script>
